<%@page pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="security" uri="/security" %>

<c:set var="BASE" value="${pageContext.request.contextPath}"/>
<c:set var="ERROR_MSG" value='${pageContext.request.getAttribute("errorMsg")}'/>
<html>
    <head>
        <title>登录</title>
    </head>
    <body>
        <h1>登录</h1>
        <c:choose>
            <c:when test=" ${ ERROR_MSG  == '' }  ">
                <span style="color:green">${ERROR_MSG}</span>
            </c:when>
            <c:otherwise>
                <span style="color:red">${ERROR_MSG}</span>
            </c:otherwise>
        </c:choose>
        <security:guest>
            <form action="${BASE}/login" method="post">
                <table>
                    <tr>
                        <td>用户名:</td>
                        <td><input type="text" name="username"></td>
                    </tr>
                    <tr>
                        <td>密码:</td>
                        <td><input type="password" name="password"></td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <button type="submit">登录</button>
                        </td>
                    </tr>
                </table>
            </form>

        </security:guest>

        <security:user>
            <c:redirect url="${BASE}/customer"/>
        </security:user>
    </body>

</html>